package com.tank.jdk8;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.Comparator;
import java.util.function.BinaryOperator;

/**
 * Created with IntelliJ IDEA.
 * User: SuQiEr
 * Date:2017/1/26
 * Time: 11:05
 * To change this template use File | Settings | File Templates.
 */
@Slf4j
public class BinaryOperatorTest {

    @Test
    public void testComputer(){
//        int result = computer(1,2,( a, b) -> a+b);
//        log.info("result:{}",result);

        String  result = minBy("hello","wor",(a,b) -> a.length() - b.length());
        log.info("result:{}",result);
    }

    public int computer(int a, int b, BinaryOperator<Integer> binaryOperator){
        return binaryOperator.apply(a,b);
    }

    public String minBy(String a,String b,Comparator<String> comparator){
        return BinaryOperator.minBy(comparator).apply(a,b);
    }


}

